import xlrd


def read03Excel(path):
    workbook = xlrd.open_workbook(path)
    sheets = workbook.sheet_names()
    worksheet = workbook.sheet_by_name(sheets[0])
    all_items = []
    for i in range(0, worksheet.nrows):
        sub_items = []
        for j in range(0, worksheet.ncols):
            sub_items.append(str(worksheet.cell_value(i, j)))
        all_items.append(sub_items)
    return all_items


file = 'bank.xls'
data = read03Excel(file)
pre_fix = 'insert into predict.expert(result'
for i in range(1, 31):
    pre_fix += ',X%d' % i
pre_fix += ') values('
f = open('out.sql', 'w', encoding='utf-8')

for sub in data:
    f.write(pre_fix+','.join(sub)+');\n')
